
	Ext.namespace("panel.widgets.chunks.calculon");
	
	panel.widgets.chunks.calculon.price = function(config) {
		
		var widget = {};
		
		widget.getResultValue = function( data, validate ) {
			
			var calculon = new panel.calculon;
			
			switch( data.modifier_type ) {
				
			case "NONE":
				return Ext.value(data.price, 0);
				break;
			
			case "NUMBER":
				
				data.modifier_value =
					validate ?
					panel.hlp.validate(data.modifier_value, "[+-price+]", "Number modifier"):
					new Number(data.modifier_value).toIntZ()
				;				
				
				break;
				
			case "FIXED":
			
				data.modifier_value =
					validate ? 
					panel.hlp.validate(data.modifier_value, "[price+]", "Fixed value"):
					new Number(data.modifier_value).toIntZ()
				;
			
				break;
				
			case "PERCENT":			
				
				data.modifier_value =
					validate ? 
					panel.hlp.validate(data.modifier_value, "[+-percent-price]", "Percent Modifier"):
					new Number(data.modifier_value).toIntZ()
				;
				
				break;
				
			}	// switch
			
			if( config.calculate ) {			
			
				calculon.setRound(0);
				calculon.setValue( data.price );
				calculon.setModifierValue( data.modifier_value );
				calculon.setModifierType( data.modifier_type );
				
				var r = calculon.calculateModifiedValue();
				
				panel.console.log(
					"Calculon:", 
					"Price",  data.price, 
					"MT",     data.modifier_type, 
					"MV",     data.modifier_value, 
					"Result", r
				);
				
				if( Ext.value(validate, false) && data.modifier_type != "NONE" ) {
					
					panel.hlp.validate(r, "[price+]", "Result price");
					
				}	// if
				
				return r;
				
			}	// if
			
		}	// 
		
		return widget;
		
	};
